package com.wz.project.kpi.controller;

import com.wz.framework.web.controller.BaseController;
import com.wz.project.kpi.service.KpiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * kpi分析controller
 *
 * @author
 * @create 2020-02-27 11:34
 */
@Controller
@RequestMapping("/kpi")
public class KpiController extends BaseController {

    private String prefix = "kpi";
    @Autowired
    private KpiService kpiService;


    @GetMapping("/spaceAnalysis")
    public String cargo()
    {
        return prefix + "/spaceAnalysis";
    }

    @GetMapping("/spacePlan")
    public String stock()
    {
        return prefix + "/spacePlan";
    }

    @GetMapping("/inAnalysis")
    public String inAnalysis()
    {
        return prefix + "/inAnalysis";
    }

    @GetMapping("/outAnalysis")
    public String outAnalysis()
    {
        return prefix + "/outAnalysis";
    }

    @GetMapping("/inAnalysisTian")
    public String inAnalysisTian()
    {
        return prefix + "/inAnalysisTian";
    }

    @GetMapping("/outAnalysisTian")
    public String outAnalysisTian()
    {
        return prefix + "/outAnalysisTian";
    }
    //库存统计
    @GetMapping("/stockAnalysis")
    public String stockAnalysis()
    {
        return prefix + "/stockAnalysis";
    }
    /**
     * 货位分析
     *
     * @return
     */
    @RequestMapping("/cs")
    @ResponseBody
    public Map<String, Long> getCargoSpaceAnalysis() {
        Map<String, Long> map = kpiService.getCargoSpaceAnalysis();
        return map;
    }

    @RequestMapping("/roadway")
    @ResponseBody
    public Map<String, String[]> getroadway() {
        Map<String, String[]> in = kpiService.getRoadway();
        return in;
    }

    @RequestMapping("/tian")
    @ResponseBody
    public Map<String, String[]> gettian() {
        Map<String, String[]> in = kpiService.getTian();
        return in;
    }
    @RequestMapping("/csbyRoadway")
    @ResponseBody
    public Map<String, Long> getCargoSpaceAnalysisByRoadWay(String roadway) {
        Map<String, Long> map = null;

        if("0".equals(roadway)){
            map = kpiService.getCargoSpaceAnalysis();
        }else {
            map = kpiService.getCargoSpaceAnalysisByRoadway(roadway);
        }
        return map;
    }

    @RequestMapping("/cs1")
    @ResponseBody
    public Map<String, Long> getCargoSpaceAnalysis1() {
        Map<String, Long> map = kpiService.getCargoSpaceAnalysis1();
        return map;
    }

    @RequestMapping("/cs2")
    @ResponseBody
    public Map<String, Long> getCargoSpaceAnalysis2() {
        Map<String, Long> map = kpiService.getCargoSpaceAnalysis2();

        return map;
    }

    @RequestMapping("/plan")
    @ResponseBody
    public Map<String, Object[]> getsSJJ(@RequestParam("roadway") int roadway,@RequestParam("platoon") int platoon) {
        Map<String, Object[]> plan = kpiService.getCargoSpacePlan(roadway,platoon);
        return plan;
    }

    /**
     * 平面图悬浮数据获取
     * @param platoon
     * @param column
     * @param floor
     * @return
     */
    @RequestMapping("/msg")
    @ResponseBody
    public Map<String, String> getMessage(Integer platoon, Integer column, Integer floor,Integer row){
        return kpiService.getMessage(platoon,column,floor,row);
    }
    @RequestMapping("/in")
    @ResponseBody
    public Map<String, long[]> getInAnalysis(@RequestParam(value = "startTime", required = false) String startTime,
                                             @RequestParam(value = "finishTime", required = false) String finishTime) {
        Map<String, long[]> in = kpiService.getMydojobFinish(startTime, finishTime,9);
        return in;
    }
    @RequestMapping("/out")
    @ResponseBody
    public Map<String, long[]> getOutAnalysis(@RequestParam(value = "startTime", required = false) String startTime,
                                             @RequestParam(value = "finishTime", required = false) String finishTime) {
        Map<String, long[]> in = kpiService.getMydojobFinish(startTime, finishTime,20);
        return in;
    }

    @RequestMapping("/intian")
    @ResponseBody
    public Map<String, Integer[]> getInTian(@RequestParam(value = "startTime", required = false) String startTime,
                                             @RequestParam(value = "finishTime", required = false) String finishTime) {
        Map<String, Integer[]> in = kpiService.getMydojobFinishs(startTime, finishTime,9);
        return in;
    }

    @RequestMapping("/outTian")
    @ResponseBody
    public Map<String, Integer[]> getOutTian(@RequestParam(value = "startTime", required = false) String startTime,
                                              @RequestParam(value = "finishTime", required = false) String finishTime) {
        Map<String, Integer[]> in = kpiService.getMydojobFinishs(startTime, finishTime,20);
        return in;
    }

    @RequestMapping("/stock")
    @ResponseBody
    public Map<String, long[]> getStock(@RequestParam(value = "startTime", required = false) String startTime,
                                          @RequestParam(value = "finishTime", required = false) String finishTime) {
        Map<String, long[]> in = kpiService.getStockdetail(startTime, finishTime);
        return in;
    }

    @RequestMapping("/stocks")
    @ResponseBody
    public Map<String, String[]> getstocks(@RequestParam(value = "startTime", required = false) String startTime,
                                           @RequestParam(value = "finishTime", required = false) String finishTime) {
        Map<String, String[]> in = kpiService.getStocks(startTime, finishTime);
        return in;
    }
}
